//
//  ViewController.m
//  启动引导页
//
//  Created by 石虎 on 2017/9/17.
//  Copyright © 2017年 石虎. All rights reserved.
//

#import "ViewController.h"
#import <AVFoundation/AVFoundation.h>
#import <MediaPlayer/MediaPlayer.h>
#import <AVKit/AVKit.h>
//#import "SHHomeViewController.h"

@interface ViewController ()

@property (strong, nonatomic) MPMoviePlayerController *player;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self videoPlayer];
}

#pragma mark - 播放
- (void)videoPlayer
{
    self.player = [[MPMoviePlayerController alloc] initWithContentURL:_movieURL];
    [self.view addSubview:self.player.view];
    self.player.shouldAutoplay = YES;
    
    [self.player setControlStyle:MPMovieControlStyleNone];
    self.player.repeatMode = MPMovieRepeatModeOne;
    
    [self.player.view setFrame:self.view.bounds];
    self.player.view.alpha = 0;
    
    [UIView animateWithDuration:3 animations:^{
        self.player.view.alpha = 1;
        [self.player prepareToPlay];
    }];
    
    [self setupLoginView];
}

#pragma mark - 登录
- (void)setupLoginView
{
    //进入按钮
    UIButton *btn = [[UIButton alloc] init];
    btn.frame = CGRectMake(24, [UIScreen mainScreen].bounds.size.height - 32 - 48, [UIScreen mainScreen].bounds.size.width - 48, 48);
    btn.layer.borderWidth = 1;
    btn.layer.cornerRadius = 24;
    btn.layer.borderColor = [UIColor whiteColor].CGColor;
    [btn setTitle:@"进入应用" forState:UIControlStateNormal];
    btn.alpha = 0;
    [self.player.view addSubview:btn];
    [btn addTarget:self action:@selector(clickBtn:) forControlEvents:UIControlEventTouchUpInside];
    
    
    [UIView animateWithDuration:3.0 animations:^{
        btn.alpha = 1.0;
    }];
}

#pragma mark - 登录点击按钮回调
- (void)clickBtn:(UIButton *)btn {
    NSLog(@"进入应用");
    //需要跳转跳转到响应的控制器
//    SHHomeViewController *home = [[SHHomeViewController alloc]init];
//    [self presentViewController:home animated:YES completion:nil];
}


@end
